package com.t235.gc.biz.service.impl;

import com.t235.gc.entity.ReplenishmentRecord;
import com.t235.gc.dao.ReplenishmentRecordDao;
import com.t235.gc.biz.service.ReplenishmentRecordService;
import org.springframework.stereotype.Service;

import javax.annotation.Resource;
import java.util.List;

/**
 * 补货记录表(ReplenishmentRecord)表服务实现类
 *
 * @author makejava
 * @since 2021-03-24 08:45:38
 */
@Service("replenishmentRecordService")
public class ReplenishmentRecordServiceImpl implements ReplenishmentRecordService {
    @Resource
    private ReplenishmentRecordDao replenishmentRecordDao;

    /**
     * 通过ID查询单条数据
     *
     * @param recordid 主键
     * @return 实例对象
     */
    @Override
    public ReplenishmentRecord queryById(Long recordid) {
        return this.replenishmentRecordDao.queryById(recordid);
    }

    /**
     * 查询多条数据
     *
     * @param offset 查询起始位置
     * @param limit  查询条数
     * @return 对象列表
     */
    @Override
    public List<ReplenishmentRecord> queryAllByLimit(int offset, int limit) {
        return this.replenishmentRecordDao.queryAllByLimit(offset, limit);
    }

    /**
     * 新增数据
     *
     * @param replenishmentRecord 实例对象
     * @return 实例对象
     */
    @Override
    public ReplenishmentRecord insert(ReplenishmentRecord replenishmentRecord) {
        this.replenishmentRecordDao.insert(replenishmentRecord);
        return replenishmentRecord;
    }

    /**
     * 修改数据
     *
     * @param replenishmentRecord 实例对象
     * @return 实例对象
     */
    @Override
    public ReplenishmentRecord update(ReplenishmentRecord replenishmentRecord) {
        this.replenishmentRecordDao.update(replenishmentRecord);
        return this.queryById(replenishmentRecord.getRecordid());
    }

    /**
     * 通过主键删除数据
     *
     * @param recordid 主键
     * @return 是否成功
     */
    @Override
    public boolean deleteById(Long recordid) {
        return this.replenishmentRecordDao.deleteById(recordid) > 0;
    }
}
